package com.aspose.cells;

import java.util.HashMap;

class zavs {
   private com.aspose.cells.b.a.zh d;
   private zavp e = new zavp();
   static com.aspose.cells.b.a.zh a = new com.aspose.cells.b.a.zh("F29F85E0-4FF9-1068-AB91-08002B27B3D9");
   static com.aspose.cells.b.a.zh b = new com.aspose.cells.b.a.zh("D5CDD502-2E9C-101B-9397-08002B2CF9AE");
   static com.aspose.cells.b.a.zh c = new com.aspose.cells.b.a.zh("D5CDD505-2E9C-101B-9397-08002B2CF9AE");

   zavs(com.aspose.cells.b.a.zh var1) {
      this.d = var1;
   }

   zavs(com.aspose.cells.b.a.zh var1, com.aspose.cells.b.a.d.za var2) throws Exception {
      this.d = var1;
      long var3 = var2.k().i();
      int var5 = var2.q();
      int var6 = var2.q();
      zavn var7 = new zavn();

      int var8;
      for(var8 = 0; var8 < var6; ++var8) {
         com.aspose.cells.b.a.a.ze.a(var7, (Object)(new zavm(var2)));
      }

      var8 = 1252;
      int var9 = var7.a(1);
      if (var9 != -1) {
         var2.k().b(var3 + (long)var9);
         short var10 = (Short)a(var2, 0);
         var8 = var10 & '\uffff';
      }

      HashMap var16 = new HashMap();
      int var11 = var7.a(0);
      if (var11 != -1) {
         var2.k().b(var3 + (long)var11);
         a(var2, var16, var8);
      }

      for(int var12 = 0; var12 < var7.size(); ++var12) {
         int var13 = var7.b(var12).a;
         if (var13 != 0 && var13 != 1) {
            var2.k().b(var3 + (long)var7.b(var12).b);
            Object var14 = a(var2, var8);
            if (var14 != null) {
               String var15 = (String)var16.get(var13);
               com.aspose.cells.b.a.a.ze.a(this.e, (Object)(new zavo(var13, var15, var14)));
            }
         }
      }

   }

   byte[] a() throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      com.aspose.cells.b.a.d.zb var2 = new com.aspose.cells.b.a.d.zb(var1, Encoding.getUnicode());
      int var3 = 8 + 8 * this.e.size();
      if (this.e.a()) {
         var3 += 8;
      }

      var3 += 8;
      var1.b((long)var3);
      zavn var4 = new zavn();
      if (this.e.a()) {
         com.aspose.cells.b.a.a.ze.a(var4, (Object)(new zavm(0, (int)var1.i())));
         a(var2, this.e);
      }

      com.aspose.cells.b.a.a.ze.a(var4, (Object)(new zavm(1, (int)var1.i())));
      a(var2, (Object)1200);

      int var5;
      for(var5 = 0; var5 < this.e.size(); ++var5) {
         zavo var6 = this.e.a(var5);
         com.aspose.cells.b.a.a.ze.a(var4, (Object)(new zavm(var6.a, (int)var1.i())));
         a(var2, var6.c);
      }

      var1.b(0L);
      var2.b((int)var1.h());
      var2.b(var4.size());

      for(var5 = 0; var5 < var4.size(); ++var5) {
         var4.b(var5).a(var2);
      }

      return var1.o();
   }

   zavp b() {
      return this.e;
   }

   com.aspose.cells.b.a.zh c() {
      return this.d;
   }

   private static void a(com.aspose.cells.b.a.d.za var0, HashMap var1, int var2) throws Exception {
      int var3 = var0.q();

      for(int var4 = 0; var4 < var3; ++var4) {
         int var5 = var0.q();
         String var6;
         if (var2 == 1200) {
            var6 = a(var0);
            zbom.a(var0.k(), 4);
         } else {
            var6 = b(var0, var2);
         }

         if (var1.get(var5) == null) {
            var1.put(var5, var6);
         } else {
            var1.put(var5, var6);
         }
      }

   }

   private static void a(com.aspose.cells.b.a.d.zb var0, zavp var1) throws Exception {
      var0.b(var1.b());

      for(int var2 = 0; var2 < var1.size(); ++var2) {
         zavo var3 = var1.a(var2);
         if (var3.a()) {
            var0.b(var3.a);
            a(var0, var3.b);
            zbom.a(var0.a(), 4);
         }
      }

   }

   private static Object a(com.aspose.cells.b.a.d.za var0, int var1) throws Exception {
      int var2 = var0.q();
      switch(var2) {
      case 2:
         return var0.n();
      case 3:
         return var0.q();
      case 5:
         return var0.u();
      case 11:
         return var0.n() != 0;
      case 19:
         return var0.r();
      case 30:
         return b(var0, var1);
      case 31:
         return a(var0);
      case 64:
         try {
            long var6 = var0.s();
            if (var6 == 0L) {
               return DateTime.a;
            }

            return zbom.a(var6, "FileTime");
         } catch (Exception var5) {
            return DateTime.getNow();
         }
      case 65:
         int var3 = var0.q();
         byte[] var4 = var0.g(var3);
         return var4;
      default:
         return null;
      }
   }

   private static void a(com.aspose.cells.b.a.d.zb var0, Object var1) throws Exception {
      if (var1 instanceof String) {
         var0.b(31);
         a(var0, com.aspose.cells.b.a.ze.e(var1));
      } else if (var1 instanceof Short) {
         var0.b(2);
         var0.a(com.aspose.cells.b.a.ze.d(var1));
      } else if (var1 instanceof Integer) {
         var0.b(3);
         var0.b(com.aspose.cells.b.a.ze.f(var1));
      } else if (var1 instanceof Long) {
         var0.b(19);
         var0.a(com.aspose.cells.b.a.ze.b(var1));
      } else if (var1 instanceof Double) {
         var0.b(5);
         var0.a(com.aspose.cells.b.a.ze.g(var1));
      } else if (var1 instanceof Boolean) {
         var0.b(11);
         boolean var2 = (Boolean)((Boolean)var1);
         var0.a((short)(var2 ? -1 : 0));
      } else if (var1 instanceof DateTime) {
         var0.b(64);
         DateTime var3 = com.aspose.cells.b.a.ze.h(var1);
         if (!DateTime.a(var3, DateTime.a)) {
            var0.b(zbom.a(var3, "FileTime"));
         } else {
            var0.b(0L);
         }
      } else {
         if (!(var1 instanceof byte[])) {
            throw new UnsupportedOperationException("Do not know how to write a property value of this type.");
         }

         var0.b(65);
         byte[] var4 = (byte[])((byte[])var1);
         var0.b(var4.length);
         var0.a(var4);
      }

      zbom.a(var0.a(), 4);
   }

   private static String b(com.aspose.cells.b.a.d.za var0, int var1) throws Exception {
      int var2 = var0.q();
      com.aspose.cells.b.a.d.zm var3 = var0.k();
      if ((long)var2 + var3.i() > var3.h()) {
         var2 = (int)(var3.h() - var3.i());
      }

      byte[] var4 = var0.g(var2);
      return com.aspose.cells.b.a.zv.a(Encoding.getEncoding(var1).a(var4, 0, var2), "\u0000", "");
   }

   private static String a(com.aspose.cells.b.a.d.za var0) throws Exception {
      int var1 = var0.q() * 2;
      byte[] var2 = var0.g(var1);
      return Encoding.getUnicode().a(var2, 0, var1 - 2);
   }

   private static void a(com.aspose.cells.b.a.d.zb var0, String var1) throws Exception {
      var0.b(var1.length() + 1);
      var0.a(Encoding.getUnicode().a(var1));
      var0.a((short)0);
   }
}
